#ifndef __TILE_HPP__
#define __TILE_HPP__

#include "Mathematics/MTriangle.hpp"

typedef enum eTileType
{
	TILE_A,
	TILE_B,
	TILE_C,
	TILE_D,
	TILE_E,
	TILE_F,
	TILE_UNKNOWN

} TILE_TYPE;

class Tile
{
public:
	Tile();
	Tile(const Tile& tile);
	Tile(TILE_TYPE type, int& iDir, double& dScale, MTriangle& triangle);
	Tile(TILE_TYPE type, int& iDir, double& dScale, MVector2D& origin, unsigned int iNewBits);
	~Tile(){}

	void reset();
	void setType(TILE_TYPE type);
	void setDirection(int iDir);
	void setScale(double dScale);
	void setOrigin(const MVector2D& origin);
	void setFCode(unsigned int iFCode);
	void setTriangle(MTriangle triangle);
	void prePendToCode(unsigned int iNewBits);

	bool         isSamplingType() const;
	int          getDir() const;
	double       getScale() const;
	unsigned int getFCode() const;
	TILE_TYPE    getType() const;

	const MTriangle& getTriangle() const;

	Tile& operator=(const Tile& tile_);

protected:
	void reCreateTile(TILE_TYPE type, int& iDir, double& dScale, MTriangle& triangle);

	TILE_TYPE     m_eType;
	int           m_iDirection;
	double        m_dScale;
    unsigned int  m_iFCode;

private:
	void   rebuildTriangle();

	MTriangle    m_triangle;
};

#endif //__TILE_HPP__

//EOF
